﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Init.PostInit.PostInitActions {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import Classes.*;
    import Display.*;
    import Modules.stats.types.*;

    public class StartupDialogBase {

        protected var m_callback:Function = null;
        protected var m_dialog:DisplayObject;
        protected var m_shouldQueue:Boolean = false;
        protected var m_loggingName:String;
        private var m_onStartUp:Boolean;

        public function StartupDialogBase(_arg1:DisplayObject, _arg2:String, _arg3:Boolean=false, _arg4:Function=null, _arg5:Boolean=true){
            this.m_dialog = _arg1;
            this.m_shouldQueue = _arg3;
            this.m_callback = _arg4;
            this.m_loggingName = _arg2;
            this.m_dialog.addEventListener(Event.CLOSE, this.onClose);
            this.m_onStartUp = _arg5;
        }
        public function get shouldQueue():Boolean{
            return (this.m_shouldQueue);
        }
        protected function isEligible():Boolean{
            return (!((this.m_dialog == null)));
        }
        final public function show():void{
            StatsManager.sample(100, StatsCounterType.DIALOG, StatsKingdomType.ANNOUNCEMENT, "view", this.m_loggingName);
            if (this.isEligible()){
                UI.displayPopup(this.m_dialog, this.m_shouldQueue, this.m_dialog.name, true);
            } else {
                this.m_callback = null;
                this.onClose();
            };
        }
        final public function showStandalone():void{
            StatsManager.sample(100, StatsCounterType.DIALOG, StatsKingdomType.ANNOUNCEMENT, "view", this.m_loggingName);
            this.m_dialog.removeEventListener(Event.CLOSE, this.onClose);
            UI.displayPopup(this.m_dialog, this.m_shouldQueue, this.m_dialog.name, true);
        }
        final public function onClose(_arg1:Event=null):void{
            StatsManager.sample(100, StatsCounterType.DIALOG, StatsKingdomType.ANNOUNCEMENT, "close", this.m_loggingName);
            this.m_dialog.removeEventListener(Event.CLOSE, this.onClose);
            if (this.m_callback != null){
                this.m_callback();
            };
            if (this.m_onStartUp){
                StartUpDialogManager.pumpDialogQueue();
            };
            this.m_dialog = null;
            this.m_callback = null;
        }

    }
}//package Init.PostInit.PostInitActions 
